﻿@model HZYProject.Domain.Course

<div class="layer-edit" style="padding:10px">
    <form id="formEdit" class="layui-form" action="" onsubmit="return false">
        <input type="hidden" name="CourseID" value="@Model.CourseID" />
        <div class="layui-form-item">
            <label class="layui-form-label">课程名称</label>
            <div class="layui-input-inline">
                <input type="text" name="Title" value="@Model.Title" required lay-verify="required" placeholder="请输入课程名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="pear-btn pear-btn-primary pear-btn-sm" lay-submit lay-filter="formDemo">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="pear-btn pear-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
</div>
@section script{
    <script>
        layui.use(['form', 'jquery'], function () {
            var form = layui.form;
            let $ = layui.jquery;
            form.on('submit(formDemo)', function (data) {
                var str = $("#formEdit").serialize();
                $.post("/Course/edit", str, function (res) {
                    if (res.success) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        }, function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        });
                    }
                    else
                        layer.msg("修改失败：" + res.msg, {
                            icon: 2,
                            time: 1000
                        });
                }, "json");
                return false;
            });
        });
    </script>
}